<script setup>
import {message} from 'ant-design-vue';
import {ref} from 'vue';
import {repairManagementAdd} from '@/api/repairManagementApi.js';
import * as commonDict from '@/utils/commonDict.js';


const open = ref(false);
const formRef = ref(null);
const emits = defineEmits(['saveSuccessful'])
import {loading} from '@/utils/loadingUtils.js';
import {MdEditor} from 'md-editor-v3';
import {fixType} from '@/utils/commonDict.js';

const form = ref({
  residentId: '',
  repairType: undefined,
  repairDescription: '',
  repairDate: '',
  status: undefined,
  createTime: '',
})




const resetForm = () => {
  formRef.value.resetFields();
  form.value.id = ''
};


const submit = async () => {
  await repairManagementAdd(form.value)
  message.success('保存成功')
  resetForm()
}

</script>

<template>

  <a-card>
    <a-form :model="form" ref="formRef" layout="vertical">
      <a-form-item
          label="报修类型"
          name="repairType"
          :rules="[{ required: true, message: '请输入报修类型' }]"
      >
        <a-select
            placeholder="请选择报修类型"
            :options="Object.keys(fixType).map(x => ({label:fixType[x],value:x}))"
            v-model:value="form.repairType"></a-select>
      </a-form-item>
      <a-form-item
          label="报修描述"
          name="repairDescription"
          :rules="[{ required: true, message: '请输入报修描述' }]"
      >
       <md-editor v-model="form.repairDescription"></md-editor>
      </a-form-item>
      <div class="flex justify-end">
        <a-button type="primary" @click="submit">提交</a-button>
      </div>
    </a-form>
  </a-card>

</template>

<style scoped>

</style>
